/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Communication;

import java.util.regex.Matcher;

/**A concrete implementation of the JHaveServerLogGrepper that looks for Visualization entries.
 * @author Aaron Heise
 */
public class VisualizationJHaveServerLogGrepper extends JHaveServerLogGrepper {
    /**Creates a new ConnectionJHaveServerLogGrepper. */
    public VisualizationJHaveServerLogGrepper() {
        super(factory.createLineGrepper("VisualizationEntry"));
    }

    /**Get the connection number found in this entry.
     * @return the connection number (as a string)
     * @throws JHaveServerLogGrepperMatchNotFinishedException the entry has not been fully loaded from the log
     */
    public String getConnectionNumber() throws JHaveServerLogGrepperMatchNotFinishedException {
        this.throwExceptionIfMatchingIsNotComplete();
        Matcher firstLine = this.grepper.getMatchingMatchers()[0];
        return firstLine.group(7);
    }

    /**Get the username found in this entry.
     * @return the username
     * @throws JHaveServerLogGrepperMatchNotFinishedException the entry has not been fully loaded from the log
     */
    public String getUsername() throws JHaveServerLogGrepperMatchNotFinishedException {
        this.throwExceptionIfMatchingIsNotComplete();
        Matcher secondLine = this.grepper.getMatchingMatchers()[1];
        return secondLine.group(7);
    }

    /**Get the visualization name found in this entry.
     * @return the visualization name
     * @throws JHaveServerLogGrepperMatchNotFinishedException the entry has not been fully loaded from the log
     */
    public String getVisualizationName() throws JHaveServerLogGrepperMatchNotFinishedException {
        this.throwExceptionIfMatchingIsNotComplete();
        Matcher secondLine = this.grepper.getMatchingMatchers()[1];
        return secondLine.group(8);
    }
}
